package com.codebuffer.nowcoder;

import java.util.*;

public class FindNumsAppearOnce {
    public int[] FindNumsAppearOnce (int[] array) {

        Map<Integer, Integer> map = new HashMap<>();
        Set<Integer> set = new TreeSet<>();
        for (int i : array) {
            int count = 1+map.getOrDefault(i,0);
            set.add(i);
            if(count>1){
                set.remove(i);
            }
            map.put(i,count);
        }
        int[] ints = new int[set.size()];
        int i=0;
        for (Integer integer : set) {
            ints[i] = integer;
            i++;
        }
        return ints;
    }
}
